package tmhprediction.eval;

import tmhprediction.classification.SecondClassifier;
import tmhprediction.classification.TMHClassifier;
import tmhprediction.main.TMHResultMap;

public class EvaluateSecondClassifier {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception
	{
		String outFolder = args[0];
		String trainFile = args[1];
		String testFile = args[2];
		int index = Integer.valueOf(args[3]);
		
		SecondClassifier sc0 = new SecondClassifier(2000);
		sc0.initializeUntrainedClassifier(trainFile, testFile);
		evaluate(sc0.getClassifierWrapper(), outFolder, index);
		
//		SecondClassifier sc1 = new SecondClassifier(2000);
//		sc1.initializeUntrainedClassifier(inFolder+"/features_manual_1.arff", inFolder+"/features_manual_2.arff");
//		evaluate(sc1.getClassifierWrapper(), outFolder, inFolder, 1);
//		
//		SecondClassifier sc2 = new SecondClassifier(2000);
//		sc2.initializeUntrainedClassifier(inFolder+"/features_manual_2.arff", inFolder+"/features_manual_0.arff");
//		evaluate(sc2.getClassifierWrapper(), outFolder, inFolder, 2);
	}

	private static void evaluate(TMHClassifier classifier, String outFolder, int index) throws Exception
	{
		TMHResultMap resM = classifier.createResultMap();
		
		System.out.println("Calculate per residue scores");
		TMHResidueEvaluator.calcPerResidueScores(resM, outFolder+"/"+index+"_scoresPerRes");
		
		System.out.println("Writing out predictions in human readable format");
		WriteOutput.writeObservedAndPredicted(resM, outFolder+"/"+index+"_readablePrediction");
		
		System.out.println("Calculating and writing out per segment scores");
		TMHHelixEvaluator.berechneFormeln(TMHHelixEvaluator.finalHelixEvaluation(resM), outFolder+"/"+index+"_scoresPerSeg");
		
		classifier.saveModel(outFolder+"/"+index+"_model.svm");
		System.out.println("Model saved");
	}
	
}
